import Taro, {Component} from '@tarojs/taro'
import {View, Image, Text} from '@tarojs/components'
import './style.scss'
import List from './list'

export default class Info extends Component {

  config = {
    navigationBarTitleText: '我的'
  }

  componentWillMount() {
  }

  componentDidMount() {
  }

  componentWillUnmount() {
  }

  componentDidShow() {
  }

  componentDidHide() {
  }

  handleClick = (value) => {
    Taro.navigateTo({
      url: `/pages/info/components/${value}/index`
    })
  };

  render() {
    return (
      <View className='info'>
        <View className='warp-flex title'>
          <View className='avatar'>
            <Image className='user-info-avatar' src='https://yscoder.github.io/img/face.jpg' backgroundSize='cover' />
          </View>
          <View className='user-info'>
            <Text className='nickname'>山大王</Text>
            <Text className='edit'>查看或编辑个人主页</Text>
          </View>
        </View>
        <View className='item-list'>
          {List.map((d, i) =>
            <View className='warp-flex' key={i} onClick={this.handleClick.bind(this, d.hash)}>
              <View className='item-icon'>
                <Image class='item-img' src={d.img} />
              </View>
              <View className='item-name'>
                <Text>{d.name}</Text>
              </View>
            </View>
          )}
        </View>
      </View>
    )
  }
}

